package zb.WX.service.msg;

import zb.WX.bean.message.Text;
import zb.WX.util.GlobalVar;
import zb.WX.util.ObjToXmlUtil;
import zb.WX.util.PropertiesUtil;

import java.util.Date;
import java.util.Map;

//返回文本消息给用户
public class TextMsg {
    private String className = this.getClass().getCanonicalName();//最为调试用

    public String getText(Map<String, String> map, String content) {
        Text text = new Text();
        text.setFromUserName(map.get("ToUserName"));
        text.setToUserName(map.get("FromUserName"));
        text.setMsgType(GlobalVar.TEXT);
        text.setCreateTime(new Date().getTime());
        text.setContent(content);
        String textXMLString = ObjToXmlUtil.objToXml(text, "xml");
        System.out.println("textXMLString：" + textXMLString);
        return textXMLString;
    }


    public static void main(String[] args) {
        System.out.println(PropertiesUtil.getPropValue("content1"));
    }
}

/*
 * 
 * 文本消息的xml格式
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1348831860</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[this is a test]]></Content>
<MsgId>1234567890123456</MsgId>
</xml>

*/

